var scope:String;

function init()
{
	Packages.model.Context.activeTool=this;

	// Event.init
	var evtTargetArr:Array=new Array();
	evtTargetArr.push(Packages.system.mlf.GateKeeper.scanElement(this._name, "searchSpot"));
	Packages.system.events.StateFulButtonEvent.initialize(evtTargetArr);

	// Render.init
	Packages.system.render.Transition.irisType1(Packages.system.mlf.GateKeeper.scanElement(this._name, "basic"));

	invokeInitComplete();
}

function dispose()
{
	Packages.system.mlf.GateKeeper.removeListener("onReleaseButtonEvent", this);
}

function invokeInitComplete()
{
	_root[this._name].swapDepths(90);

	Packages.system.mlf.GateKeeper.addListener("onReleaseButtonEvent", this);

	// select the first scopt option as default
	var bookOptSpot=Packages.system.mlf.GateKeeper.scanElement(this._name, "bookOptSpot");
	var param=mlf.mcmanager.PathResolver.drawPath(bookOptSpot);
	Packages.system.events.StateFulButtonEvent.invokeReleaseEvent(param, data, this._name);
}

function doSearch()
{
	var keyword=Packages.system.utils.TextUtil.getValue("searchKeywordValue", this._name);
	if (keyword=="") return;

	if (scope=="books")
	{	
		Packages.model.Context.address.keyword=keyword;
		Packages.components.SceneAgent.loadScene("content/bookPage/BookList?keyword");
	}
	else if (scope=="members")
	{
		//
		Packages.model.Context.address.keyword=keyword;
		Packages.components.SceneAgent.loadScene("content/MemberList?keyword");
	}
	else if (scope=="groups")
	{
		// Packages.components.SceneAgent.loadScene("content/groups/GroupList?keyword="+escape(keyword));
	}
	
	// Packages.modula.RequestCommand.request("HTTP", "restlet/"+scope+"/"+escape(keyword)+"?startIndex=0&count=10", null, null, null, this, null);
}

function onReleaseButtonEvent(evt:Object)
{
	if (evt.param=="searchSpot")
	{
		doSearch();
	}
	else if (evt.param=="bookOptSpot")
	{
		scope="books";
	}
	else if (evt.param=="memberOptSpot")
	{
		scope="members";
	}
	else if (evt.param=="groupOptSpot")
	{
		scope="groups";
	}
}